window.datas = {
    //地区信息
    addressInfo:[],
};

//获取省份
function getAddressInfo(callback){
    $.ajax({
        url: "/commonProvince",
        type: "get",
        dataType: "json",
        success:(data)=>{
            window.datas.addressInfo=data.data;
            $(".dfProvince").html('<option value="">请选择省份</option>')
            window.datas.addressInfo.forEach((item,index)=>{
                $(".dfProvince").append(`<option value="${item.id}">${item.pname}</option>`)
            });
            if (callback){
                callback();
            }
        }
    })
}
//选择省份之后
function provinceChange(){
    let addressInfo=datas.addressInfo;
    let city=[];
    let id=$(".dfProvince option:selected").val();
    for (let i = 0;i< addressInfo.length; i++) {
        if(addressInfo[i].id==id){
            city=addressInfo[i].citys;
            break;
        }
    }
    $(".dfCity").html('<option value="">请选择城市</option>')
    city.forEach((item,index)=>{
        $(".dfCity").append(`<option value="${item.id}">${item.cname}</option>`);
    })
}
